<?php
	$nameAdv=$_POST['nameAdv'];
	$linkAdv=$_POST['linkAdv'];
	$position=$_POST['position'];
	$state=$_POST['state'];
	
	$target="../user/upload/adv/";
	$link=$target.$_FILES['imgpath']['name'];
	if(move_uploaded_file($_FILES['imgpath']['tmp_name'],$link)==true){
		$query="INSERT INTO advertisements(nameAdv,linkAdv,imgpath,position,state) VALUES ('$nameAdv','$linkAdv','$link','$position','$state')";
		mysql_query($query);
		echo "Thêm quảng cáo thành công.";	
		echo "<script>window.location='index.php?admin=advAdmin&do=listadv'</script>";	
	}	
?>